import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '@/views/home'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    name: 'home',
    component: home,
    redirect: '',
    children: [
      {
        path: '',
        name: 'mainpage',
        component: () => import('@/views/mainpage')
      },
      {
        path: 'explore',
        name: 'explore',
        component: () => import('@/views/explore')
      },
      {
        path: '404',
        name: 'notfound',
        component: () => import('@/views/404')
      },
      {
        path: '*',
        redirect: '/404'
      }
    ]
  },
  {
    path: '*',
    redirect: '/login'
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
